﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Kimd.Communication
{
    public interface ISocketClient : ISocket
    {
        /// <summary>
        /// 是否连接
        /// </summary>
        bool IsConnected { get;}
        /// <summary>
        /// 接收信息事件
        /// </summary>
        event EventHandler<TcpClientDatagramReceivedEventArgs<byte[]>> DatagramReceived;

        /// <summary>
        /// 连接
        /// </summary>
        /// <returns></returns>
        bool Connect();
        /// <summary>
        /// 断开连接
        /// </summary>
        /// <returns></returns>
        bool Disconnect();

        /// <summary>
        /// 发送信息,返回发送状态,接收结果
        /// </summary>
        /// <param name="send"></param>
        /// <param name="receive"></param>
        /// <param name="waitTime"></param>
        /// <returns></returns>
        bool Send(byte[] data, out string receive, int timeout = 500);
        /// <summary>
        /// 发送信息,返回发送状态,接收结果
        /// </summary>
        /// <param name="send"></param>
        /// <param name="receive"></param>
        /// <param name="waitTime"></param>
        /// <returns></returns>
        bool Send(byte[] data, out byte[] receive, int timeout = 500);
        /// <summary>
        /// 发送信息,返回发送状态
        /// </summary>
        /// <param name="send"></param>
        /// <param name="waitTime"></param>
        /// <returns></returns>
        bool Send(byte[] data);
        /// <summary>
        /// 发送信息,返回发送状态,接收结果
        /// </summary>
        /// <param name="send"></param>
        /// <param name="waitTime"></param>
        /// <returns></returns>
        bool Send(String data, out string receive, int timeout = 500);
        /// <summary>
        /// 发送信息,返回发送状态,接收结果
        /// </summary>
        /// <param name="send"></param>
        /// <param name="receive"></param>
        /// <param name="waitTime"></param>
        /// <returns></returns>
        bool Send(String data, out byte[] receive, int timeout = 500);
        /// <summary>
        /// 发送信息,返回发送状态
        /// </summary>
        /// <param name="send"></param>
        /// <param name="waitTime"></param>
        /// <returns></returns>
        bool Send(String data);

    }
}
